<template>
	<view>
		<view class="">
			<view class="fs28 ">
				<view class="mt-4 ml-4">当前绑定的手机号是：{{list.mobile}}</view>
			</view>
			<view class="input d-flex">
				<image src="@/static/img/login/yanzhengma.png" mode="widthFix" style="width: 40rpx;"></image>
				<input class="flex-1" type="text" v-model="code" placeholder="请输入验证码">
				<view style="color: #e80909; font-size: 28rpx;" @tap="openCode">获取验证码</view>
			</view>
			<!-- <view class="">绑定手机号后</view> -->
			<button class="btn" @tap="newCode">下一步</button>
		</view>

		<view class="ls2 ml-4 fs28">

		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				list: {},
				code: ''
			};
		},
		onLoad() {
			this.getusif()
		},
		methods: {
			async getusif() {
				let res = await this.$myRequest({
					url: '/getUserInfo',
					methods: 'POST',
					data: {
						token: uni.getStorageSync('token')
					}
				})
				if (res.data.status == 1) {
					this.list = res.data.data
					// console.log(this.list)
				}
				uni.$emit('phone', {
					phone: this.list
				})
			},

			async newCode() {
				if (this.code.length <= 0) {
					uni.showToast({
						title: '请先获取验证码',
						icon: "none"
					})
					return
				}

				uni.navigateTo({
					url: './newCode?code=' + this.code
				})
			},
			async openCode() {
				let res = await this.$myRequest({
					url: '/getCode/' + this.list.mobile
				})
				uni.showToast({
					title: '发送成功',
					icon: "none"
				})
			},
		},
	}
</script>

<style lang="scss">
	page {
		background-color: #f5f5f5;
	}

	.input {
		width: 82%;
		height: 100%;
		margin: 20rpx auto;
		border: 2rpx solid #f5f5f5;
		background-color: white;
		padding: 30rpx;
		border-radius: 20rpx;
	}

	input {
		padding: 0 20rpx;
	}

	.btn {
		border-radius: 10rpx;
		color: white;
		background-color: #e80909;
		margin: 40rpx;
	}

	.bg {
		font-size: 28rpx;

		background-color: #f4e9ea;
	}

	.phone {
		color: #999;
		margin-top: 20rpx;
	}
</style>
